package pkg

import "k8s.io/klog"

// validator validate a equal b
type validator interface {
	validate(src,tag []Button,wineImage,windowsImage string)bool
}

type attrValidator struct {
}

func newAttrValidator()*attrValidator{
	return &attrValidator{}
}
func (v *attrValidator)validate(src,tag []Button,wineImage,windowsImage string)bool{
	if len(src)!=len(tag){
		return false
	}
	src=sortButtons(src)
	tag=sortButtons(tag)
	for i:=range src{
		if src[i].Name!=tag[i].Name || src[i].ButtonType!=tag[i].ButtonType{
			return false
		}
	}
	// validate images
	wineButton,err:=ocrImage(wineImage,true)
	if err!=nil{
		klog.Errorf("validate with error:%v",err)
	}
	windowsButton,err:=ocrImage(windowsImage,false)
	if err!=nil{
		klog.Errorf("validate with error:%v",err)
	}
	return isSimilar(wineButton,windowsButton)
}
